<template>
  <el-dialog :visible.sync="dialogVisible" width="800px" :before-close="handleClose" :close-on-click-modal="false"
    append-to-body :title="title">
    <el-form :model="form" ref="formRef" label-width="90px">
      <el-form-item label="审核备注" prop="pass_remark" :rules="[
          { required: true, message: '请输入审核备注', trigger: 'blur' },
        ]">
        <el-input resize="none" type="textarea" :autosize="{ minRows: 2, maxRows: 4 }" placeholder="请输入"
          v-model="form.pass_remark"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="tx-c">
      <el-button style="width: 200px" type="danger" @click="handleClose('2')">取消</el-button>
      <el-button type="primary" style="width: 200px" @click="confirm('1')" :loading="btnLoading">提交</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { debounce } from "@/util";
import { ApiOrderReviewHandle } from "@/api/index.js";
import ImgUploadPath from "@/components/imgUpload-path.vue";
import { validatePhone } from "@/util/validate";
export default {
  props: ["roleData", "departmentData"],
  components: {
    ImgUploadPath,
  },
  data() {
    return {
      oldform: {
        pass_remark: "",
        /*    unit: "京山市人民医院", */
      },
      form: {},
      btnLoading: false,
      dialogVisible: false,
      id: null,
      title: "",
    };
  },

  methods: {
    confirm: debounce(
      function (val) {
        this.$refs["formRef"].validate(async (valid) => {
          if (valid) {
            this.btnLoading = true;
            try {
              await ApiOrderReviewHandle(this.id, {
                ...this.form,
                pass: val,
              });
              this.$message.success("修改成功");
              this.handleClose();
              this.$emit("refresh");
            } finally {
              this.btnLoading = false;
            }
          } else return false;
        });
      },
      500,
      true
    ),

    show(row) {
      console.log("12121", row);
      if (row) {
        this.id = row.id;
      }
      this.dialogVisible = true;
    },

    handleClose() {
      this.dialogVisible = false;
      this.form = { ...this.oldform };
      /*  this.$nextTick((_) => {
        this.$refs.formRef.clearValidate();
        this.$refs.ImgUploadPath.clear();
      }); */
    },
  },
};
</script>

<style></style>
